//
//  HCMineExchangeViewController.m
//  HappyChildren
//
//  Created by WillyZhao on 2017/5/12.
//  Copyright © 2017年 WillyZhao. All rights reserved.
//

#import "HCMineExchangeViewController.h"

#import "HCMineExchangeModel.h"

#import "HCExchangeMineView.h"

@interface HCMineExchangeViewController () {
    HCMineExchangeModel *model;
}

@property (nonatomic, strong) HCExchangeMineView *exchangeView;

@end

@implementation HCMineExchangeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.textTitle = @"我的兑换";
    
    if (![PublicFunction isNull:HCGETUSER(@"userid")]) {
        self.dataRequest.delegate = self;
        [self.dataRequest post_HCMineExchange:HCGETUSER(@"userid")];
    }
    
    // Do any additional setup after loading the view.
}


-(void)dataRequesterFail:(DataRequester *)requester requesterWithType:(DataRequestType)aType receiveErrorDictionary:(NSDictionary *)dictionary {
    NSLog(@"请求失败");
}

-(void)dataRequesterFinish:(DataRequester *)requester requesterWithType:(DataRequestType)aType receiveDictionary:(NSDictionary *)dictionary {
    NSLog(@"我的兑换请求成功:%@",dictionary);
    
    model = [[HCMineExchangeModel alloc] initWithDictionary:dictionary error:nil];
    self.exchangeView = [[HCExchangeMineView alloc] initWithFrame:CGRectMake(0, 0, self.centerView.frame.size.width, self.centerView.frame.size.height)];
    self.exchangeView.model = model;
    [self.centerView addSubview:self.exchangeView];
    
    __weak typeof (self)weakSelf = self;
    [weakSelf.exchangeView setDidClickExchangeCellBlock:^(NSString *gid){
        
        [weakSelf pushChildrenViewController:@"HCGGoodsDetailViewController" parameterObject:gid dataObject:nil];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
